package top.zywork.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.zywork.dao.SearchHistoryDAO;
import top.zywork.dos.SearchHistoryDO;
import top.zywork.dto.SearchHistoryDTO;
import top.zywork.service.AbstractBaseService;
import top.zywork.service.SearchHistoryService;

import javax.annotation.PostConstruct;
import java.util.List;

/**
 * SearchHistoryServiceImpl服务接口实现类<br/>
 *
 * 创建于2019-10-18<br/>
 *
 * @author http://zywork.top 王振宇
 * @version 1.0
 */
@Service(value = "searchHistoryService")
public class SearchHistoryServiceImpl extends AbstractBaseService implements SearchHistoryService {

    private SearchHistoryDAO searchHistoryDAO;

    @Override
    public List<String> listUserHisKeywordsByCount(Long userId, Integer total) {
        return searchHistoryDAO.listUserHisKeywordsByCount(userId, total);
    }

    @Override
    public List<String> listHotKeywordsByCount(int total) {
        return searchHistoryDAO.listHotKeywordsByCount(total);
    }

    @Override
    public int removeAllByUserId(Long userId) {
        return searchHistoryDAO.removeAllByUserId(userId);
    }

    @Override
    public int removeByKeyword(Long userId, String keyword) {
        return searchHistoryDAO.removeByKeyword(userId, keyword);
    }

    @Autowired
    public void setSearchHistoryDAO(SearchHistoryDAO searchHistoryDAO) {
        super.setBaseDAO(searchHistoryDAO);
        this.searchHistoryDAO = searchHistoryDAO;
    }

    @PostConstruct
    public void init() {
        super.init(SearchHistoryDO.class, SearchHistoryDTO.class);
    }
}
